import Vue from 'vue'
import VXETable from "vxe-table";
import "vxe-table/lib/index.css";
import "xe-utils";
Vue.use(VXETable);
import Cookies from 'js-cookie'
import 'normalize.css/normalize.css' // a modern alternative to CSS resets
import Element from 'element-ui'
import './styles/element-variables.scss'
import '@/styles/index.scss' // global css
import App from './App'
import store from './store'
import router from './router'
// import router from './router/indexNew'
import axios from 'axios'
import VueAxios from 'vue-axios'
import qs from 'qs'
import './icons' // icon
import './permission' // permission control
import './utils/error-log' // error log
import * as filters from './filters' // global filters
import global from '@/global.js'
import XLSX from "xlsx";
import Print from 'vue-print-nb'
import BaiduMap from 'vue-baidu-map'
import echarts from 'echarts'

import i18n from './i18n'
import moment from "moment";
// import VueI18n from 'vue-i18n'
// Vue.use(VueI18n)

Vue.prototype.$moment = moment;
Vue.prototype.$echarts = echarts
Vue.use(XLSX);
Vue.use(Print); //注册
VXETable.setup({
    validArgs: 'obsolete' // 将自定义校验参数还原为 Function(rule, cellValue, callback)
  })
Vue.use(BaiduMap, {
    ak: 'jvxxteX7pzUr24FqQAhgBuFtlkgdvMcl'
})


Date.prototype.format = function(fmt) {
        var o = {
            "M+": this.getMonth() + 1, //月份
            "d+": this.getDate(), //日
            "h+": this.getHours(), //小时
            "m+": this.getMinutes(), //分
            "s+": this.getSeconds(), //秒
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
            "S": this.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        }
        for (var k in o) {
            if (new RegExp("(" + k + ")").test(fmt)) {
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            }
        }
        return fmt;
    }
    /*
     * 重写时间的toJSON方法，因为在调用JSON.stringify的时候，时间转换就调用的toJSON，这样会导致少8个小时，所以重写它的toJSON方法
     */
Date.prototype.toJSON = function() {
    return this.format("yyyy-MM-dd hh:mm:ss"); // util.formatDate是自定义的个时间格式化函数
}

Vue.prototype.$qs = qs
Vue.prototype.$axios = axios

Vue.prototype.$global = global
    // 配置全局的axios默认值（可选）
    // var AUTH_TOKEN = ''
axios.defaults.baseURL = global.host + '/api'
    // axios.defaults.headers.common['Authorization'] = AUTH_TOKEN
    // axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'

Vue.use(VueAxios, axios)
Vue.prototype.HOST = '/api'
    /**
     * If you don't want to use mock-server
     * you want to use MockJs for mock api
     * you can execute: mockXHR()
     *
     * Currently MockJs will be used in the production environment,
     * please remove it before going online ! ! !
     */
    // if (process.env.NODE_ENV === 'production') {
    //  const { mockXHR } = require('../mock')
    //  mockXHR()
    // }

Vue.use(Element, {
    size: Cookies.get('size') || 'medium' // set element-ui default size
})

// register global utility filters
Object.keys(filters).forEach(key => {
    Vue.filter(key, filters[key])
})

//关闭Vue的生产提示
Vue.config.productionTip = false
Vue.config.warnHandler = function (msg, vm, trace) {  
    // 什么都不做，忽略所有警告  
  }

new Vue({
    el: '#app',
    router,
    store,
    i18n, 
    render: h => h(App)
})